/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2020-2022. All rights reserved.
 * Description:
 * Author: g00421808
 * Create: 6/24/2022
 * Notes:
 */

#ifndef JSBIND_XLASS_H
#define JSBIND_XLASS_H

#include <forward_list>

#include "jsbind/binder/binder.h"
#include <node_api.h>
#include "jsbind/function.h"

namespace Jsb {

class JSBIND_EXPORT ClassBase {
public:
    ClassBase();

    virtual ~ClassBase() = default;

    void Init(const char *name);

    virtual const napi_ref* GetClassRefs() = 0;

    virtual void SetClassRefs(napi_ref* originalRef) = 0;

    void AddMethod(const char* name, int32_t invokerId, Binder* binder);

    const char* GetName() {return name_;}

    const Binder* GetBinder() const {return binder_;}

    std::forward_list<Function>& GetMethods() { return methods_;}

    uint32_t GetWrapperConstructorGroupId() const { return wrapperConstructorGroupId_; }

    uint32_t GetValueConstructorGroupId() const { return valueConstructorGroupId_; }

protected:
    const char* name_;

    Binder* binder_;

    uint32_t wrapperConstructorGroupId_;

    uint32_t valueConstructorGroupId_;

    std::forward_list<Function> methods_;
};
} // namespace Jsb

#endif //JSBIND_XLASS_H
